package com.sh.high_grade_component;

import android.database.DataSetObserver;
import android.os.Bundle;
import android.os.Debug;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.SpinnerAdapter;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class SpinnerDropdownActivity extends AppCompatActivity implements AdapterView.OnItemClickListener, AdapterView.OnItemSelectedListener {

    private Spinner spinner;

    private final static String[] strArray = {"1", "2", "3", "4", "5"};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_spinner_dropdown);

        spinner = findViewById(R.id.sp_dropdown);
        ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(this, R.layout.item_select, strArray);
        spinner.setAdapter(arrayAdapter);
        spinner.setSelection(2);

        spinner.setOnItemSelectedListener(this);
    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

    }

    @Override
    public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
        System.out.println("============================");
        System.out.println(position);
        System.out.println("============================");
        System.out.println(id);
        System.out.println("=============================");




    }

    @Override
    public void onNothingSelected(AdapterView<?> parent) {

    }
}